import Vue from 'vue'
import Vuex from 'vuex'
import user from '@/store/modules/user'
import getters from './getters'

Vue.use(Vuex)

const store = new Vuex.Store({
  modules: {
    user
  },
  getters,
  mutations: {
    SET_OPENID(state, openId) {
      state.user.openId = openId  // 在 user 模块内设置 openid
    },
	// 清除 openid
	  CLEAR_OPENID(state) {
	    state.user.openId = null; // 或者 undefined，根据你的需求
	  },
	  
	SET_RANGE(state, range) {
	  state.user.range = range  
	},
	// 清除 openid
	  CLEAR_RANGE(state) {
	    state.user.range = null; 
	  }
  },
  actions: {
    // 添加一个 action 以便在组件中方便地提交 openid
    setOpenId({ commit }, openId) {
      commit('SET_OPENID', openId)
    },
	
	setRange({ commit }, range) {
	  commit('SET_RANGE', range)
	}
  }
})

export default store
